package com.nantai.jiafang.nantaijiafang.activity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nantai.jiafang.nantaijiafang.R;
import com.nantai.jiafang.nantaijiafang.bean.ProductionOrderInfo;

import java.util.List;

/**
 * Created by wuning on 2016/8/9.
 */
public class ProductionOrderListAdapter extends BaseAdapter {

    private List<ProductionOrderInfo> list;
    private Context mContext;

    public ProductionOrderListAdapter(Context context, List<ProductionOrderInfo> data) {
        mContext = context;
        list = data;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.productionorderdetail, null);
            viewHolder = new ViewHolder();
            viewHolder.tv1_1 = (TextView) convertView.findViewById(R.id.tv1_1);
            viewHolder.tv1_2 = (TextView) convertView.findViewById(R.id.tv1_2);
            viewHolder.tv1_3 = (TextView) convertView.findViewById(R.id.tv1_3);
            viewHolder.tv1_4 = (TextView) convertView.findViewById(R.id.tv1_4);
            viewHolder.tv1_5 = (TextView) convertView.findViewById(R.id.tv1_5);
            viewHolder.tv1_6 = (TextView) convertView.findViewById(R.id.tv1_6);
            viewHolder.tv1_7 = (TextView) convertView.findViewById(R.id.tv1_7);
            viewHolder.tv1_8 = (TextView) convertView.findViewById(R.id.tv1_8);
            viewHolder.tv1_9 = (TextView) convertView.findViewById(R.id.tv1_9);
            viewHolder.tv1_10 = (TextView) convertView.findViewById(R.id.tv1_10);
            viewHolder.tv1_11 = (TextView) convertView.findViewById(R.id.tv1_11);
            viewHolder.tv1_12 = (TextView) convertView.findViewById(R.id.tv1_12);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.tv1_1.setText(list.get(position).getDocNo());
        viewHolder.tv1_2.setText(list.get(position).getcInvName());
        viewHolder.tv1_3.setText(list.get(position).getcInvAddCode());
        viewHolder.tv1_4.setText(list.get(position).getComponentInvName());
        viewHolder.tv1_5.setText(list.get(position).getComponentInvCode());
        viewHolder.tv1_6.setText(list.get(position).getcVenCode());
        viewHolder.tv1_7.setText(list.get(position).getLevels());
        viewHolder.tv1_8.setText(list.get(position).getCutCost());
        viewHolder.tv1_9.setText(list.get(position).getPickLength());
        viewHolder.tv1_10.setText(list.get(position).getUseRatePercentText());
        viewHolder.tv1_11.setText(list.get(position).getTimestamp());
        viewHolder.tv1_12.setText(list.get(position).getCutSuitQty());
        return convertView;
    }

    class ViewHolder {
        TextView tv1_1, tv1_2, tv1_3, tv1_4, tv1_5, tv1_6, tv1_7, tv1_8, tv1_9, tv1_10,tv1_11,tv1_12;
    }
}
